/*
    Copyright (C) 2025 mio <stigma@disroot.org>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef PLAYLIST_H
#define PLAYLIST_H

#include <tqobject.h>

#include <kurl.h>

class Playlist : public TQObject
{
    TQ_OBJECT

public:
    explicit Playlist(TQObject *parent = nullptr);
    ~Playlist();

    /*! Add a new item */
    void append(const KURL& mrl);
    /*! Append multiple items to the playist. */
    void append(const KURL::List& items);
    /*! Is the playlist empty */
    bool isEmpty() const;
    /*! Returns the number of items in the playlist. */
    int count() const;
    /*! Returns the index of the current item in the playlist. */
    int currentIndex() const;
    /*! Returns the current item in the playlist. */
    KURL currentItem() const;
    /*! Remove the item at position \a index from the playlist. */
    bool remove(int index);

    /*! The MRL for the item at \p index */
    KURL at(int index) const;

signals:
    /*!
     * Emitted whenever the playlist index changes.
     *
     * \see currentIndex()
     */
    void currentIndexChanged(int index);
    /*!
     * Emitted whenever the playlist index changes.
     *
     * \see currentItem()
     */
    void currentItemChanged(const KURL& item);
    /*!
     * Emitted whenever items are added/inserted into the playlist.
     *
     * \see append()
     */
    void itemsInserted(int start, int end);
    /*!
     * Emitted whenever items are removed from the playlist.
     *
     * \see remove()
     */
    void itemsRemoved(int start, int end);

public slots:
    /*! Advance to the next playlist item. */
    void next();
    /*! Return to the previous playlist item. */
    void previous();
    /*! Navigate to the playlist item at \a index. */
    void setCurrentIndex(int index);

private:
    class PlaylistPrivate* d;
};

#endif /* PLAYLIST_H */
